package models
{
	import flash.media.Camera;
	import flash.media.Microphone;
	import flash.net.SharedObject;

	[Bindable]
	public class LocalSetting
	{
		public var so:SharedObject = SharedObject.getLocal("localSetting");
		public function set userName(v:String):void{
			setValue("userName",v);
		}
		public function get userName():String{
			return so.data["userName"];
		}
		public function get camera():int{
			return so.data["camera"];
		}
		public function set camera(v:int):void{
			setValue("camera",v);
		}
		public function get microphone():int{
			return so.data["microphone"];
		}
		public function set microphone(v:int):void{
			setValue("microphone",v);
		}
		private function setValue(name:String,value:Object):void{
			so.data[name] = value;
			try{
				so.flush();
			}catch(e:Error){
				
			}
		}
		public function get cam():Camera{
			if(camera < Camera.names.length){
				return Camera.getCamera(camera.toString());
			}else{
				return Camera.getCamera();
			}
		}
		public function get mic():Microphone{
			if(microphone< Microphone.names.length){
				return Microphone.getMicrophone(microphone);
			}else{
				return Microphone.getMicrophone();
			}
		}
	}
}